//注册
let regist = (req,res) => {
    let body = req.body
    let name = body.name
    let pwd = body.pwd
    global.username = name
    global.userpwd = pwd
    res.send("注册成功")
}
//登录
let login = (req,res) => {
    let query = req.query
    let name = query.name
    let pwd = query.pwd

    console.log(`当前全局用户名 ${global.username},当前全局密码 ${global.userpwd}`)
    
    if (name == username && pwd == userpwd){
        res.send("登录成功")
    }else{
        throw new Error("用户名或密码错误")
    }

}

//获取用户信息
// let getUserInfo = (req,res) => {
//     let header = req.headers
//     let token = header.token
//     res.cookie('key','val')
//     res.send({
//         name :"weihao",
//         class : "xunke",
//         token:token,
//     })
// }

module.exports={regist,login}